#include "testrack.h"

#include <QTest>
#include <QFile>
/*
Automatic clinic tests using a robot arm.
Copyright (C) 2010  CIC-CPC, CHU Gabriel Montpied
All other trademarks, logos and copyrights are the property
of their respective owners.

This file is part of cpc-painbot.

cpc-painbot is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

cpc-painbot is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with cpc-painbot.  If not, see <http://www.gnu.org/licenses/>.
*/
#include <QDebug>

#include "rack.h"
#include "filament.h"

#include "positionbras.h"

void TestRack::testCharger()
{
    QFile source(":/donnees/vonfrey.xml");
    source.open(QIODevice::ReadOnly | QIODevice::Text);
    Rack *rack = Rack::charger(&source, this);
    QString description(
        "Ce rack sert d'exemple. Il contient différents filaments, utilisés pour réaliser"
        " une courbe de détermination de seuil."
    );

    QVERIFY(rack != 0);

    QCOMPARE(rack->nom(), QString("Von Frey"));
    QCOMPARE(rack->description(), description);
    QCOMPARE(rack->hauteur(), 15.5);
    QCOMPARE(rack->espacement(), 30.);
    QCOMPARE(*rack->position(), PositionBras(-170, 390));
    QCOMPARE(rack->filaments().size(), 2);

    foreach (int e, rack->emplacements()) {
        QVERIFY(rack->filament(e) != 0);
        qDebug() << '#' << e << ':' << *rack->filament(e);
    }

    QVERIFY(rack->filament(0) == 0);
    QVERIFY(rack->filament(5) == 0);

    // Test d'un fichier mal formatté.
}
